package ace.module.oauth2.server.core.impl.dao.entity;

import jakarta.annotation.Nullable;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.experimental.SuperBuilder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.annotation.Version;
import org.springframework.data.relational.core.mapping.Table;
import jakarta.validation.constraints.Size;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotEmpty;
import java.io.Serializable;
import ace.cmp.spring.data.jdbc.querydsl.core.annotations.LogicDelete;
import ace.cmp.spring.graphql.core.model.GenericPageContent;
import ace.module.oauth2.server.api.model.dto.Oauth2RegisteredClientDto;

/**
* oauth2 客户端.
*
* @author Caspar
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = Oauth2RegisteredClientDto.TABLE_DESC)
@Table(Oauth2RegisteredClientDto.TABLE_NAME)
public class Oauth2RegisteredClient implements Serializable, GenericPageContent<String> {

  @Id
  @Size(max = 255)
  @Schema(title = Oauth2RegisteredClientDto.ID_TITLE, description = Oauth2RegisteredClientDto.ID_DESC)
  private String id;

  @Size(max = 255)
  @Schema(title = Oauth2RegisteredClientDto.CLIENT_ID_TITLE, description = Oauth2RegisteredClientDto.CLIENT_ID_DESC)
  private String clientId;

  @Schema(title = Oauth2RegisteredClientDto.CLIENT_ID_ISSUED_AT_TITLE, description = Oauth2RegisteredClientDto.CLIENT_ID_ISSUED_AT_DESC)
  private Long clientIdIssuedAt;

  @Nullable
  @Size(max = 255)
  @Schema(title = Oauth2RegisteredClientDto.CLIENT_SECRET_TITLE, description = Oauth2RegisteredClientDto.CLIENT_SECRET_DESC)
  private String clientSecret;

  @Nullable
  @Schema(title = Oauth2RegisteredClientDto.CLIENT_SECRET_EXPIRES_AT_TITLE, description = Oauth2RegisteredClientDto.CLIENT_SECRET_EXPIRES_AT_DESC)
  private Long clientSecretExpiresAt;

  @Size(max = 255)
  @Schema(title = Oauth2RegisteredClientDto.CLIENT_NAME_TITLE, description = Oauth2RegisteredClientDto.CLIENT_NAME_DESC)
  private String clientName;

  /**
   * {@link ace.module.oauth2.server.api.enums.Oauth2RegisteredClientClientAuthenticationMethodsEnum}
   */
  @Size(max = 255)
  @Schema(title = Oauth2RegisteredClientDto.CLIENT_AUTHENTICATION_METHODS_TITLE, description = Oauth2RegisteredClientDto.CLIENT_AUTHENTICATION_METHODS_DESC)
  private String clientAuthenticationMethods;

  /**
   * {@link ace.module.oauth2.server.api.enums.Oauth2RegisteredClientAuthorizationGrantTypesEnum}
   */
  @Size(max = 255)
  @Schema(title = Oauth2RegisteredClientDto.AUTHORIZATION_GRANT_TYPES_TITLE, description = Oauth2RegisteredClientDto.AUTHORIZATION_GRANT_TYPES_DESC)
  private String authorizationGrantTypes;

  @Schema(title = Oauth2RegisteredClientDto.REDIRECT_URIS_TITLE, description = Oauth2RegisteredClientDto.REDIRECT_URIS_DESC)
  private String redirectUris;

  @Schema(title = Oauth2RegisteredClientDto.SCOPES_TITLE, description = Oauth2RegisteredClientDto.SCOPES_DESC)
  private String scopes;

  /**
   * {@link org.springframework.security.oauth2.server.authorization.settings.ClientSettings}
   */
  @Schema(title = Oauth2RegisteredClientDto.CLIENT_SETTINGS_TITLE, description = Oauth2RegisteredClientDto.CLIENT_SETTINGS_DESC)
  private String clientSettings;

  /**
   * {@link org.springframework.security.oauth2.server.authorization.settings.TokenSettings}
   */
  @Schema(title = Oauth2RegisteredClientDto.TOKEN_SETTINGS_TITLE, description = Oauth2RegisteredClientDto.TOKEN_SETTINGS_DESC)
  private String tokenSettings;

  @LogicDelete
  @Size(max = 255)
  @Schema(title = Oauth2RegisteredClientDto.DELETE_FLAG_TITLE, description = Oauth2RegisteredClientDto.DELETE_FLAG_DESC)
  private String deleteFlag;

  @CreatedDate
  @Schema(title = Oauth2RegisteredClientDto.CREATE_TIME_TITLE, description = Oauth2RegisteredClientDto.CREATE_TIME_DESC)
  private Long createTime;

  @LastModifiedDate
  @Schema(title = Oauth2RegisteredClientDto.UPDATE_TIME_TITLE, description = Oauth2RegisteredClientDto.UPDATE_TIME_DESC)
  private Long updateTime;

  @Version
  @Schema(title = Oauth2RegisteredClientDto.ROW_VERSION_TITLE, description = Oauth2RegisteredClientDto.ROW_VERSION_DESC)
  private Long rowVersion;

}
